<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const arr = [1, 2, 3];
        Array.prototype.getSome = function (getCondition) {
            for (let i = 0; i < this.length; i++) {
                const condition = getCondition(this[i]);
                if (condition) {
                    return true;
                }
                return false;
            }
        }
       console.log(arr.getSome(item => item === 2));

       Array.prototype.getFindIndex = function (getCondition) {
            for (let i = 0; i< this.length; i++) {
                const condition = getCondition(this[i]);
                if (condition) {
                    return i;
                }
            }
            return -1;
        }
       console.log(arr.getFindIndex(item => item === 3));

       Array.prototype.getFilter = function (getCondition) {
           const res = [];
           for (const item of this) {
               const condition = getCondition(item);
               if (condition) {
                   res.push(item);
               }
           }
           return res;
       }
       console.log(arr.getFilter(item => item <= 2));

       Array.prototype.getEvery = function (getCondition) {
           for (const item of this) {
               const condition = getCondition(item);
               if (!condition) {
                   return false;
               }
           }
           return true;
       }
       console.log(arr.getEvery(item => item <= 2));
    </script>
</body>
</html>